﻿#ifndef PRODUCTPICKER_H
#define PRODUCTPICKER_H

#include <QDialog>
#include "productservice.h"
#include "submitproductwidget.h"

namespace Ui {
class ProductPicker;
}

class ProductPicker : public QDialog
{
    Q_OBJECT

public:
    explicit ProductPicker(QWidget *parent = nullptr);
    ~ProductPicker();
//setSelectionMode(QAbstractItemView::SingleSelection);//设置一次只能选中一行
    void setSelectionMode(QAbstractItemView::SelectionMode mode);

    void showAndInit();
signals:
    void selectedFinished(QList<Product*> products, int defaultCount);

    void singleSelected(Product *product, int defaultCount);

private slots:
    void on_lineEditProductOverallQuery_textChanged(const QString &arg1);

    void on_lineEditProductTypeQuery_textChanged(const QString &arg1);

    void on_lineEditProductNameQuery_textChanged(const QString &arg1);

    void on_pushButtonProductClearQuery_clicked();

    void on_pushButtonUpdateProductData_clicked();

    void on_pushButtonCancel_clicked();

    void on_pushButtonNewProduct_clicked();

    void on_pushButtonSelectReturn_clicked();

    void on_comboBox_currentIndexChanged(int index);

private:
    Ui::ProductPicker *ui;
    ProductService productService;
    SubmitProductWidget newProductWidget;

    QAbstractItemView::SelectionMode selectionMode;
};

#endif // PRODUCTPICKER_H
